package com.irdstudio.efp.nls.service.impl.ms;

import com.irdstudio.basic.framework.core.constant.BaseConstant;
import com.irdstudio.basic.framework.core.exception.QueuePauseException;
import com.irdstudio.basic.framework.core.util.StringUtil;
import com.irdstudio.basic.framework.core.util.TimeUtil;
import com.irdstudio.basic.framework.core.util.ValidationUtils;
import com.irdstudio.efp.console.service.facade.CustomerLimitInfoService;
import com.irdstudio.efp.console.service.vo.CustomerLimitInfoVO;
import com.irdstudio.efp.esb.common.constant.ESBClientConstance;
import com.irdstudio.efp.esb.service.bo.req.MsYxApproveReqBean;
import com.irdstudio.efp.esb.service.bo.resp.MsYxApproveRespBean;
import com.irdstudio.efp.esb.service.facade.esb.EsbService;
import com.irdstudio.efp.nls.service.facade.NlsApplyInfoService;
import com.irdstudio.efp.nls.service.facade.NlsQueueSoltComnService;
import com.irdstudio.efp.nls.service.facade.ed.LimitControlsService;
import com.irdstudio.efp.nls.service.facade.ms.MsZxInfoService;
import com.irdstudio.efp.nls.service.impl.SoltServiceImpl;
import com.irdstudio.efp.nls.service.vo.MsZxInfoVO;
import com.irdstudio.efp.nls.service.vo.NlsApplyInfoVO;
import com.irdstudio.efp.nls.service.vo.queue.NlsProcessBizVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 需求编号：xxxxxx<br/>
 * 问题编号：<br/>
 * 功能描述：马上金融联合贷用信审批服务<br/>
 * 开发人员：tiankg<br/>
 * 创建时间：2020/5/9 17:21
 * @Version 1.0
 * @Since 1.0
 */
@Service("msLoanApprService")
public class MsLoanApprServiceImpl extends SoltServiceImpl {

    private static Logger logger = LoggerFactory.getLogger(MsLoanApprServiceImpl.class);
    public final String customerLimitInfoSts = "01";
    public final String  cusType = "02";

    @Autowired
    @Qualifier("msZxService")
    private MsZxInfoService msZxInfoService;//马上征信基本信息

    @Autowired
    @Qualifier("nlsApplyInfoService")
    private NlsApplyInfoService nlsApplyInfoService;// 网贷申请基本信息

    @Autowired
    @Qualifier("limitControlsService")
    private LimitControlsService limitControlsService;// 已占用额度

    @Autowired
    @Qualifier("customerLimitInfoService")
    private CustomerLimitInfoService customerLimitInfoService;//客户限额

    @Autowired
    @Qualifier("nlsQueueSoltComnService")
    private NlsQueueSoltComnService nlsQueueSoltComnService; // 告警服务

//    @Autowired
//    @Qualifier("msYxApprService")
//    private MsYxApprService msYxApprService;//马上金融用信审批服务

    @Autowired
    @Qualifier("msYxApprService")
    private EsbService<MsYxApproveReqBean, MsYxApproveRespBean> msApproveService;



    @Override
    protected void doExecute(NlsProcessBizVO nlsProcessBizVo, NlsApplyInfoVO nlsApplyInfoVO) throws Exception {

        String applySeq = nlsApplyInfoVO.getApplySeq();
        logger.info("======>马上金融联合贷用信审批服务开始,流水号" + applySeq + "<======");
        try {
            BigDecimal sumAmt = BigDecimal.ZERO;
            BigDecimal amtLimit = BigDecimal.ZERO;

            MsZxInfoVO inMsZxInfoVo = new MsZxInfoVO();
            inMsZxInfoVo.setApplySeq(applySeq);
            MsZxInfoVO msZxInfo = msZxInfoService.queryByPk(inMsZxInfoVo);//获取马上征信信息
            Objects.requireNonNull(msZxInfo,"马上金融联合贷用信审批获取马上征信信息为空");

            sumAmt = limitControlsService.getPreOccAmt(nlsApplyInfoVO.getCertCode(), nlsApplyInfoVO.getCertType());//网贷贷款已占用额度

            CustomerLimitInfoVO customerLimitInfoVO = new CustomerLimitInfoVO();
            customerLimitInfoVO.setSts(customerLimitInfoSts);
            customerLimitInfoVO.setCusType(cusType);
            customerLimitInfoVO = customerLimitInfoService.queryByStsAndCusTyp(customerLimitInfoVO);//客户限额
            Objects.requireNonNull(customerLimitInfoVO,"马上金融联合贷用信审批获取客户限额为空");

            if (customerLimitInfoVO.getQuotaLimiAmt() != null) {
                if (TimeUtil.compareDates(TimeUtil.getCurDate(), customerLimitInfoVO.getStrDt()) > -1 && TimeUtil.compareDates(TimeUtil.getCurDate(), customerLimitInfoVO.getEndDt()) < 1) {
                     amtLimit = customerLimitInfoVO.getQuotaLimiAmt();
                }
            }

            int age = ValidationUtils.getAgeFromIdNumber(nlsApplyInfoVO.getCertCode(), BaseConstant.MS_AGE_START_22, BaseConstant.MS_AGE_END_55);//男性
            boolean isFemale = ValidationUtils.isFemale(nlsApplyInfoVO.getCertCode());
            if (isFemale) {
                age = ValidationUtils.getAgeFromIdNumber(nlsApplyInfoVO.getCertCode(), BaseConstant.MS_AGE_START_22, BaseConstant.MS_AGE_END_50);//女性
            }

            // 调用用信审批接口三次
            invokeApproveInterface(nlsApplyInfoVO,msZxInfo,applySeq,sumAmt,amtLimit,age);
            throw new QueuePauseException("");//等待风控审批，此处不赋值，不然插槽中会对拒绝原因进行修改，而审批通过后原逻辑对拒绝原因字段是不处理的。

        }catch (Exception e){
            logger.error("======>网贷【用信审批服务】执行失败原因为<======" + e.getMessage());
            if (!(e instanceof QueuePauseException)) {
                logger.error("======>网贷【用信审批服务】插槽执行失败！！！<======");
            }
            nlsProcessBizVo.setExceptionFlag(Boolean.TRUE);
            nlsProcessBizVo.setRefuseMsg(e.getMessage());
            nlsProcessBizVo.setExceptionMsg(e);
        }finally {
            logger.info("======>马上金融联合贷用信审批服务结束,流水号" + applySeq + "<======");
        }

    }

    private void invokeApproveInterface(NlsApplyInfoVO nlsApplyInfoVO,MsZxInfoVO msZxInfo,String applySeq, BigDecimal sumAmt, BigDecimal amtLimit,int age) throws Exception{
        MsYxApproveReqBean msZxApproveReqBeanArr = new MsYxApproveReqBean();
        MsYxApproveReqBean.QryRptsInfArry msZxApproveReqBean = new MsYxApproveReqBean.QryRptsInfArry();
        if (StringUtil.isNullorBank(nlsApplyInfoVO.getIndivIdExpDt())){//证件有效期为空，则直接传风控
            msZxApproveReqBean.setIdentVldty(nlsApplyInfoVO.getIndivIdExpDt());//证件有效期
        }else{
            msZxApproveReqBean.setIdentVldty(indivIdExpDt(nlsApplyInfoVO.getIndivIdExpDt()));
        }
        msZxApproveReqBean.setAppNo(applySeq);//申请编号
        msZxApproveReqBean.setName(nlsApplyInfoVO.getCusName());//姓名
        msZxApproveReqBean.setGnd(nlsApplyInfoVO.getCusGender());//性别
        msZxApproveReqBean.setAge(Integer.toString(age));//年龄
        msZxApproveReqBean.setIdentTp(nlsApplyInfoVO.getCertType());//证件类型
        msZxApproveReqBean.setIdentNo(nlsApplyInfoVO.getCertCode());//证件号码
        msZxApproveReqBean.setCrr(nlsApplyInfoVO.getProfession());//职业
        msZxApproveReqBean.setCrspAddr(nlsApplyInfoVO.getCertAddr());//联系人地址
        msZxApproveReqBean.setNation(nlsApplyInfoVO.getCusNational());//国籍
        msZxApproveReqBean.setCustLmt(amtLimit.toString());//客户限额
        msZxApproveReqBean.setNetwrkLoanOcptnLmt(sumAmt.toString());//网络贷款占用额度
        msZxApproveReqBean.setTlrNo("gzyh123");//柜员号（待业务确认，暂时随便赋值）
        msZxApproveReqBean.setDeptNo(ESBClientConstance.InstId);//部门编号（赋值：ESB头部常量机构id）
        msZxApproveReqBean.setMblNo(nlsApplyInfoVO.getMobile());//电话号码
        msZxApproveReqBean.setCrCardOdueJdg(msZxInfo.getGzyhLCOverdue());//贷记卡逾期判断
        msZxApproveReqBean.setCrCardStJdg(msZxInfo.getGzyhIsCFrozen());//贷记卡状态判断
        msZxApproveReqBean.setCrCardRctly12MosInsdAcmlnOdueTms(msZxInfo.getGzyhCTotalPdNum12m());//贷记卡最近12个月内累计逾期次数
        msZxApproveReqBean.setCrCardCtnsOdueJdg(msZxInfo.getGzyhCMaxContinuePdNum12m());//贷记卡连续逾期判断
        msZxApproveReqBean.setGnrCmpnstJdg(msZxInfo.getGzyhNumGuacmp());//保证人代偿判断
        msZxApproveReqBean.setBdDbtJdg(msZxInfo.getGzyhNumTbd());//呆账判断
        msZxApproveReqBean.setAstDispJdg(msZxInfo.getGzyhNumAssdsp());//资产处置判断
        msZxApproveReqBean.setLoanOdueJdg(msZxInfo.getGzyhLLOverdue());//贷款逾期判断
        msZxApproveReqBean.setLoanStJdg(msZxInfo.getGzyhIsLOvdue());//贷款状态判断
        msZxApproveReqBean.setCllctnAcctSt(msZxInfo.getGzyhIsLCollecting());//催收账户状态
        msZxApproveReqBean.setLoanClsfSt(msZxInfo.getGzyhIfFiveClassUnnormal());//贷款分类状态
        msZxApproveReqBean.setLoanRcntOdueTms(msZxInfo.getGzyhLTotalPdNum12m());//贷款近期逾期次数
        msZxApproveReqBean.setLoanCtnsOdueJdg(msZxInfo.getGzyhLMaxContinuePdNum12m());//贷款连续逾期判断
        msZxApproveReqBean.setCustInfJdg(msZxInfo.getGzyhIfHaveBasicInfo());//客户信息判断
        msZxApproveReqBean.setNrOneMosQryTms(msZxInfo.getGzyh1MCardEnquiriesLC());//近一个月查询次数
        msZxApproveReqBean.setNnLoanRcrdJdg(msZxInfo.getGzyhIsCreditWhite());//无贷款记录判断
        msZxApproveReqBean.setQscrdtOdueJdg(msZxInfo.getGzyhLSOverdue());//准贷记卡逾期判断
        msZxApproveReqBean.setQscrdtSt(msZxInfo.getGzyhIsSFrozen());//准贷记卡状态
        msZxApproveReqBean.setQscrdtOdNonRpymtRcrdJdg(msZxInfo.getGzyhIsSOvdueMThan180D());//准贷记卡透支未还记录判断
        msZxApproveReqBean.setQscrdtOdSt(msZxInfo.getGzyhSTotalPdNum12m());//准贷记卡近期逾期次数
        msZxApproveReqBean.setQscrdtCtnsOdueJdg(msZxInfo.getGzyhSMaxContinuePdNum12m());//准贷记卡连续逾期判断
        msZxApproveReqBean.setSnglBnkHghstCrLmt(msZxInfo.getGzyhAmtcHclacc());//单家行最高授信额
        msZxApproveReqBean.setTotCrLmt(msZxInfo.getGzyhAmtcClop());//总授信额度
        msZxApproveReqBean.setAlrdyCrLmt(msZxInfo.getGzyhAmtcUtlcop());//已使用额度
        msZxApproveReqBean.setOdueSnglMonHghstOdueTotAmt(msZxInfo.getGzyhAmtcHtpdever());//逾期单月最高逾期总额
        msZxApproveReqBean.setLoanCrLoanBrchCnt(msZxInfo.getGzyhNumlLpos());//贷款授信贷款机构数
        msZxApproveReqBean.setRctlyAcmlnOdueCnt(msZxInfo.getGzyhTotalLoanOverdueNum()); //最近累计逾期期数
        msZxApproveReqBean.setPBCIdy(msZxInfo.getGzyhInd());//人行行业
        msZxApproveReqBean.setEnfrcExecJdg(msZxInfo.getGzyhIsEnforement());//强制执行判断
        msZxApproveReqBean.setCrCardRctlyAcmlnOdueTrmCnt(msZxInfo.getGzyhTotaCrelOverdueNum());//信用卡最近累计逾期期数
        msZxApproveReqBean.setSmlLndBrchCrBrchCnt(msZxInfo.getGzyhSmallCNum());//小贷机构授信机构数
        msZxApproveReqBean.setSmlLndBrchHvLndBrchCnt(msZxInfo.getGzyhSmallLoanNum());//小贷机构有贷机构数
        msZxApproveReqBean.setSmlLndBrchHvLndDbllCnt(msZxInfo.getGzyhSmallLoanLoanNum());//小贷机构有贷借据数
        msZxApproveReqBean.setCnsmnFinBrchCrBrchCnt(msZxInfo.getGzyhFinancialCreditInsNum());//消费金融机构授信机构数
        msZxApproveReqBean.setCnsmnFinBrchHvLndBrchCnt(msZxInfo.getGzyhFinancialLoanInsNum());//消费金融机构有贷机构数
        msZxApproveReqBean.setCnsmnFinBrchHvLndDbllCnt(msZxInfo.getGzyhFinancialLoanLoanInsNum());//消费金融机构有贷借据数
        msZxApproveReqBean.setCrnOdueTrmCnt(msZxInfo.getGzyhLCOverdueNum());//当前逾期期数
        msZxApproveReqBean.setCrnOdueAmt(msZxInfo.getGzyhLCCpdSum());//当前逾期金额
        msZxApproveReqBean.setCrnLmtUseFrqcy(msZxInfo.getGzyhCurrentQuotaUsage());//当前额度使用率
        msZxApproveReqBean.setBalNoForNonBalCrCardShetCnt(msZxInfo.getGzyhLCNo0CardNum());//余额不为零余额贷记卡张数
        msZxApproveReqBean.setUncldHsngMrtgeLoanCnt(msZxInfo.getGzyhUnOverMortgageLoanNum());//未结清住房按揭贷款笔数
        msZxApproveReqBean.setUncldCrpnLoanCnt(msZxInfo.getGzyhUnOverBusinessLoanNum());//未结清经营性贷款笔数
        msZxApproveReqBean.setUncldLoanCnt(msZxInfo.getGzyhUnOverOtherLoanNum());//未结清贷款笔数
        msZxApproveReqBean.setWhthrExstExtGrnt(msZxInfo.getGzyhIsNumExtwrt());//是否存在对外担保
        msZxApproveReqBean.setUncldLoanCntSmzg(msZxInfo.getGzyhNumlOs());//未结清贷款笔数汇总
        msZxApproveReqBean.setWhthrAbnStCrCard(msZxInfo.getGzyhLCAbnormalCard());//是否异常状态贷记卡
        msZxApproveReqBean.setWhthrAbnStQscrdt(msZxInfo.getGzyhLSAbnormalCard());//是否异常状态准贷记卡
        msZxApproveReqBean.setWhthrExstAbnLoan(msZxInfo.getGzyhLLAbnormalLoan());//是否存在异常贷款
        msZxApproveReqBean.setMrtlSitu(msZxInfo.getGzyhStuMrg());//婚姻状况
        msZxApproveReqBean.setHghstEdu(msZxInfo.getGzyhDiploma());//最高学历
        msZxApproveReqBean.setHghstDgr(msZxInfo.getGzyhDegree());//最高学位
        msZxApproveReqBean.setLoanCrBal(msZxInfo.getGzyhAmtlOsbal());//贷款授信余额
        msZxApproveReqBean.setUncldLoanCrRpymnt(msZxInfo.getGzyhAmtlApos6m());//未结清贷款授信平均应还款
        msZxApproveReqBean.setUncldCrCardCrBrchCnt(msZxInfo.getGzyhNumcLpop());//未结清贷记卡授信贷款机构数
        msZxApproveReqBean.setNonCnslAcctCrCardCrAvUseLmt(msZxInfo.getGzyhAmtcAutlcop6m());//未销户贷记卡授信平均使用额度
        msZxApproveReqBean.setGrntCnt(msZxInfo.getGzyhNumExtwrt());//担保笔数
        msZxApproveReqBean.setGrntPnpBal(msZxInfo.getGzyhAtmExtwrt());//担保本金余额
        msZxApproveReqBean.setHsngLoanCnt(msZxInfo.getGzyhAtmExtwrt());//住房贷款笔数
        msZxApproveReqBean.setIndvCmrclHsngLoanCnt(msZxInfo.getGzyhPersonalCommercialLoans());//个人商用房贷款笔数
        msZxApproveReqBean.setCrCardLngstAcctAge(msZxInfo.getGzyhLCLongestAge());//贷记卡最长账龄
        msZxApproveReqBean.setLoanPnpBal(msZxInfo.getGzyhAmtlBalSum());//贷款本金余额
        msZxApproveReqBean.setLoanUncldCnt(msZxInfo.getGzyhUnfinishLoans());//贷款未结清笔数
        msZxApproveReqBean.setCrpnLoanBal(msZxInfo.getGzyhOperLoanBalance());//经营性贷款余额
        msZxApproveReqBean.setFrmrLoanBal(msZxInfo.getGzyhFarmerLoanBalance());//农户贷款余额
        msZxApproveReqBean.setIndvCnsmnLoanBal(msZxInfo.getGzyhPersonalLoanBalance());//个人消费贷款余额
        msZxApproveReqBean.setCnsmnFinCoLoanBal(msZxInfo.getGzyhCFianceCompanyLoanBalance());//消费金融公司贷款余额
        msZxApproveReqBean.setSmlLndCoLoanBal(msZxInfo.getGzyhSmallLoanCompanyBanlance());//小贷公司贷款余额
        msZxApproveReqBean.setRctly1MosInsdCrCardQryBrchCnt(msZxInfo.getGzyh1MCardEnquiries());//最近1个月内信用卡查询机构数
        msZxApproveReqBean.setRctly3MosInsdCrCardQryBrchCnt(msZxInfo.getGzyh3MCardEnquiries());//最近3个月内信用卡查询机构数
        msZxApproveReqBean.setRctly6MosInsdCrCardQryBrchCnt(msZxInfo.getGzyh6MCardEnquiries());//最近6个月内信用卡查询机构数
        msZxApproveReqBean.setRctly12MosInsdCrCardQryBrchCnt(msZxInfo.getGzyh12MCardEnquiries());//最近12个月内信用卡查询机构数
        msZxApproveReqBean.setRctly24MosInsdCrCardQryBrchCnt(msZxInfo.getGzyh24MCardEnquiries());//最近24个月内信用卡查询机构数
        msZxApproveReqBean.setRctly1MosInsdLoanQryBrchCnt(msZxInfo.getGzyh1MLoanEnquiries());//最近1个月内贷款查询机构数
        msZxApproveReqBean.setRctly3MosInsdLoanQryBrchCnt(msZxInfo.getGzyh3MLoanEnquiries());//最近3个月内贷款查询机构数
        msZxApproveReqBean.setRctly6MosInsdLoanQryBrchCnt(msZxInfo.getGzyh6MLoanEnquiries());//最近6个月内贷款查询机构数
        msZxApproveReqBean.setRctly12MosInsdLoanQryBrchCnt(msZxInfo.getGzyh12MLoanEnquiries());//最近12个月内贷款查询机构数
        msZxApproveReqBean.setRctly24MosInsdLoanQryBrchCnt(msZxInfo.getGzyh24MLoanEnquiries());//最近24个月内贷款查询机构数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM1Tms(msZxInfo.getGzyh12MOverdueM1());//信用卡最近12个月逾期和违约M1的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM2Tms(msZxInfo.getGzyh12MOverdueM2());//信用卡最近12个月逾期和违约M2的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM3Tms(msZxInfo.getGzyh12MOverdueM3());//信用卡最近12个月逾期和违约M3的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM4Tms(msZxInfo.getGzyh12MOverdueM4());//信用卡最近12个月逾期和违约M4的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM1UpTms(msZxInfo.getGzyh12MOverdueBigThanM1());//信用卡最近12个月逾期和违约M1及以上的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM2UpTms(msZxInfo.getGzyh12MOverdueBigThanM2());//信用卡最近12个月逾期和违约M2及以上的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM3UpTms(msZxInfo.getGzyh12MOverdueBigThanM3());//信用卡最近12个月逾期和违约M3及以上的次数
        msZxApproveReqBean.setCrCardRctly12MosOdueAndDfltM4UpTms(msZxInfo.getGzyh12MOverdueBigThanM4());//信用卡最近12个月逾期和违约M4及以上的次数
        msZxApproveReqBean.setCrCardRctly12MosMxOdueSumDfltTrmCnt(msZxInfo.getGzyh12MMaxOverdueNum());//信用卡最近12个月最大逾期和违约期数
        msZxApproveReqBean.setCrCardRctly24MosMxOdueSumDfltTrmCnt(msZxInfo.getGzyh24MMaxOverdueNum());//信用卡最近24个月最大逾期和违约期数
        msZxApproveReqBean.setCrnLoanOdueAndDfltTotAmt(msZxInfo.getGzyhCurrentAmtlCpdSum());//当前贷款逾期和违约总额
        msZxApproveReqBean.setCrnLoanOdueAndDfltTrmCnt(msZxInfo.getGzyhCurrentAmtlCpdMax());//当前贷款逾期和违约期数
        msZxApproveReqBean.setLoanRctly12MosOdueAndDfltM1UpTms(msZxInfo.getGzyh12MlldOverdueBigThanM1());//贷款最近12个月逾期和违约M1及以上的次数
        msZxApproveReqBean.setLoanRctly24MosOdueAndDfltM1UpTms(msZxInfo.getGzyh24MlldOverdueBigThanM1());//贷款最近24个月逾期和违约M1及以上的次数
        msZxApproveReqBean.setLoanRctly12MosOdueAndDfltM2UpTms(msZxInfo.getGzyh12MlldOverdueBigThanM2());//贷款最近12个月逾期和违约M2及以上的次数
        msZxApproveReqBean.setLoanRctly24MosOdueAndDfltM2UpTms(msZxInfo.getGzyh24MlldOverdueBigThanM2());//贷款最近24个月逾期和违约M2及以上的次数
        msZxApproveReqBean.setLoanRctly12MosOdueAndDfltM3UpTms(msZxInfo.getGzyh12MlldOverdueBigThanM3());//贷款最近12个月逾期和违约M3及以上的次数
        msZxApproveReqBean.setLoanRctly24MosOdueAndDfltM3UpTms(msZxInfo.getGzyh24MlldOverdueBigThanM3());//贷款最近24个月逾期和违约M3及以上的次数
        msZxApproveReqBean.setLoanRctly12MosOdueAndDfltM4UpTms(msZxInfo.getGzyh12MlldOverdueBigThanM4());//贷款最近12个月逾期和违约M4及以上的次数
        msZxApproveReqBean.setLoanRctly24MosOdueAndDfltM4UpTms(msZxInfo.getGzyh24MlldOverdueBigThanM4());//贷款最近24个月逾期和违约M4及以上的次数
        msZxApproveReqBean.setLoanRctly12MosMxOdueAndDfltTms(msZxInfo.getGzyh12MlldOverdueMax());//贷款最近12个月最大的逾期和违约期数
        msZxApproveReqBean.setLoanRctly24MosMxOdueAndDfltTms(msZxInfo.getGzyh24MlldOverdueMax());//贷款最近24个月最大的逾期和违约期数
        msZxApproveReqBean.setRprtTm(msZxInfo.getTIME_REP());//报告时间
        msZxApproveReqBean.setCardSnglHghstLmtUseRt(msZxInfo.getGzyhCMaxUsedRate());//卡单笔最高额度使用率
        msZxApproveReqBean.setNr3MosAprvlQry(msZxInfo.getGzyh3MCardEnquiriesLC());//近3个月审批查询
        msZxApproveReqBean.setUncldLoanBrchCnt(msZxInfo.getGzyhUnclosedLoanInsNum());//未结清贷款机构数量
        msZxApproveReqBean.setUncldLoanContrTotAmt(msZxInfo.getGzyhUnclosedLoanContrAmt());//未结清贷款合同总额
        msZxApproveReqBean.setRsrvFld1("");//预留字段1
        msZxApproveReqBean.setRsrvFld2("");//预留字段2
        msZxApproveReqBean.setRsrvFld3("");//预留字段3
        msZxApproveReqBean.setRsrvFld4("");//预留字段4
        msZxApproveReqBean.setRsrvFld5("");//预留字段5
        msZxApproveReqBean.setRsrvFld6("");//预留字段6
        msZxApproveReqBean.setRsrvFld7("");//预留字段7
        msZxApproveReqBean.setRsrvFld8("");//预留字段8
        msZxApproveReqBean.setRsrvFld9("");//预留字段9
        msZxApproveReqBean.setRsrvFld10("");//预留字段10

        List<MsYxApproveReqBean.QryRptsInfArry> qryRptsInfArries = new ArrayList<>();
        qryRptsInfArries.add(msZxApproveReqBean);
        msZxApproveReqBeanArr.setQryRptsInfArrys(qryRptsInfArries);

//        EsbInvokeWrapper esbInvokeWrapper = new EsbInvokeWrapper(msYxApprService, msZxApproveReqBeanArr, nlsQueueSoltComnService);
//        esbInvokeWrapper.invoke3Threes();
        MsYxApproveRespBean service = msApproveService.service(msZxApproveReqBeanArr);
//        if (!MsLoanConstant.RetCodeEnum.SUCCESS.VALUE.equals(service.getQryRptsInfArry().get(0).getRcvSt())){//非成功返回
//                nlsQueueSoltComnService.alarmNotice(EsbBizEnums.AlarmObjectName.OCM_REAL_TIME.getValue(), EsbBizEnums.AlarmLvl.SERIOUS.getValue(),"用信阶段风控审批接口调用失败");//调用告警
//        }

    }

    /**
     * 证件有效期截取
     * @param indivIdExpDt
     */
    public String indivIdExpDt(String indivIdExpDt) {
        String[] indiv = indivIdExpDt.split("-");
        if("长期".equals(indiv[1])) {
            return "长期";
        }else{
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            try {
                return sf.format(sdf.parse(indiv[1]));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return "";
    }
}
